#include "physics/pplanet.h"

#include <QDomElement>

PPlanet::PPlanet(PWorld *world, QString name) : PObject(world, QString("planet_%1").arg(name))
{
    setM(2);
    setR(5);
    setLife(100000);
}

void PPlanet::serialize(QDomDocument *doc, QDomElement *e) const {
    e->setAttribute("type", "Planet");
    PObject::serialize(doc, e);
}

PPlanet *PPlanet::deserialize(QDomNode *e, PWorld *parent) {
    PObject *obj = PObject::deserialize(e, 0);
    PPlanet *planet = new PPlanet(parent, obj->getName());
    planet->setBrightness(obj->getBrightness());
    planet->setDamage(obj->getDamage());
    planet->setLife(obj->getLife());
    planet->setM(obj->getM());
    planet->setPos(obj->getPos());
    planet->setR(obj->getR());
    planet->setV(obj->getV());

    delete obj;
    return planet;
}
